#ifndef SCENE_LOADER2
#define SCENE_LOADER2

#include <GL\glui.h>
#include <string>
#include <map>

#include "tinyxml.h"
#include "Texture.h"
#include "Material.h"
#include "Primitive.h"
#include "Component.h"
#include "Translate.h"
#include "Rotate.h"
#include "Scale.h"
#include "RectangleP.h"
#include "TriangleP.h"
#include "CylinderP.h"
#include "TorusP.h"
#include "SphereP.h"
#include "Scene.h"
#include "View.h"
#include "Perspective.h"
#include "Ortho.h"
#include "Illumination.h"
#include "OmniL.h"
#include "SpotL.h"
#include <utility>

using std::string;
using std::map;
using std::vector;
using std::pair;

class SceneLoader{
public:
	SceneLoader(string fd);
	int getNextTexID();

	bool init();
	bool readFile();
	bool validateFile();

	bool loadScene();
	bool loadViews();
	bool loadPrimitives();
	bool loadTextures();
	bool loadMaterials();
	bool loadTransformations();
	bool loadComponents();
	bool parseComponents();
	bool loadIllumination();
	bool loadLights();

	Component* getComponent(string id);
	Component* getMultMats(char id);
	Material * getMaterial(string id);
	Texture * getTexture(string id);
	Primitive * getPrimitive(string id);
	View * getView(string id);
	Light* getLight(string id);
	Transformation * getTransformation(string id);
	Illumination* getIllumination();

	void cycleComponents();
	void cycleLights();
	void changeMatByKey(char c);
	int getNumberOfLights();
	int getNumberOfViews();

	Scene * getSceneInfo();
	void setSceneInfo(Scene *s);
	void CurrentViewAct();
	void setCurrentViewID(string d);
	void setCurrentViewIDbyIndex(int d);
	string getCurrentViewID();

	pair<string,Light*> getLightByIndex(int i);
	pair<string,View*> getViewByIndex( int i );
	void getLightAttenuation( int atten );
	map<string,Transformation*> transformations;
	map<string,Primitive*> primitives;
private:
	string filename,currentView;
	int textureID, nlights;
	
	map<string,Texture*> textures;
	map<string,Material*> materials;
	map<char,Component*> multMats;
	map<string,Component*> components;
	map<string,View*> views;
	map<string,Light*> lights;
	Illumination * illumination;

	vector<Component*> tempComponents;
	vector<vector<string> > tempIDComponent;

	Scene * sceneInfo;

	TiXmlDocument doc;
}; 

#endif